home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 21.zip / BS1 part 21 / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].7z / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].adf / rexx.lzh / AutoImport.pprx < prev    next >
Text File  |  1993-01-28  |  3KB  |  123 lines

  1. /*
  2. @BAutoImport  @P@ICopyright Gold Disk Inc. Jan, 1993
  3.  
  4. This Genie will import text into a page and create as many copies of the current page as necessary to fit the text.
  5. */
  6.  
  7. call SafeEndEdit.rexx()
  8. call ppm_AutoUpdate(0)
  9. address command
  10.  
  11. currentpage = ppm_CurrentPage()
  12.  
  13. if currentpage ~= 0 then
  14. do
  15. /*
  16.  *  Page exists, select box
  17.  */
  18.     filename = ppm_GetFileName("Open Text File:", "PPage:", "")
  19.     if filename = '' then call exit_msg()
  20.     box = ppm_ClickOnBox("Click on box in which to import text")
  21. end
  22. else
  23. do
  24. /*
  25.  *  No page exists, make from default
  26.  */
  27.     filename = ppm_GetFileName("Open Text File:", "PPage:", "")
  28.     if filename = '' then call exit_msg()
  29.     currentpage = ppm_CreatePage(1,1,1,1,0)
  30.     box = ppm_PageFirstBox(currentpage)
  31.     if box = '' then call exit_msg("No box on default page, cannot import text.")
  32. end
  33.  
  34. if box = 0 then exit
  35. info    = ppm_GetBoxInfo(box)
  36. fword   = upper(word(info, 1))
  37. lword   = word(info, words(info))
  38.  
  39. if fword ~= "EMPTY" & lword ~= "0" then exit_msg("You must select an empty text box to use this Genie")
  40. if word(info, 3) = 1 | word(info, 1) = word(info, 3) then leave
  41.  
  42. prevbox = box
  43. outbox = 0
  44.  
  45. do forever
  46.     prevbox = ppm_ArtNextBox(prevbox)
  47.     if prevbox = 0 | ppm_BoxPage(prevbox) ~= currentpage then leave
  48.     outbox = prevbox
  49. end
  50.  
  51. /*
  52.  * Box must be empty
  53.  */
  54. if ~ ppm_ImportText( box, filename ) then
  55.     call exit_msg("Could not import "filename)
  56.  
  57. todo    = ppm_TextOverFlow( box )
  58.  
  59. if ~todo then exit_msg("Done")
  60. boxoff = boxoffset(box, currentpage)
  61. if outbox = 0 then
  62. do
  63.     outbox = box
  64.     outboxoff = boxoff
  65. end
  66. else
  67.     outboxoff = boxoffset(outbox, currentpage)
  68.  
  69. do while todo
  70.     call ppm_CopyPage(currentpage, currentpage, 1)
  71.     call ppm_MovePage(currentpage, currentpage + 1)
  72.     currentpage = currentpage + 1
  73.     box = ppm_PageFirstBox(currentpage)
  74.     fbox = box
  75.     do boxoff
  76.         box = ppm_PageNextBox(box)
  77.     end
  78.     call ppm_DeleteContents(box)
  79.     call ppm_LinkBox(outbox, box)
  80.     outbox = fbox
  81.     do outboxoff
  82.         outbox = ppm_PageNextBox(outbox)
  83.     end
  84.     todo = ppm_TextOverFlow( outbox )
  85.  
  86.     if todo then
  87.     do
  88.                 info    = ppm_GetBoxInfo(box)
  89.                 b_width = word(info,5)
  90.                 if (b_width = 0) then exit_msg("Word too wide for box.")
  91.     end
  92. end
  93.  
  94. call exit_msg("Done")
  95.  
  96. /*
  97.  *  Box Offset Procedure
  98.  */
  99. boxoffset: procedure
  100. do
  101.     arg box, page
  102.     cbox = ppm_PageFirstBox(page)
  103.     bcount = 0
  104.     do while cbox ~= 0
  105.         if cbox = box then return(bcount)
  106.         cbox = ppm_PageNextBox(cbox)
  107.         bcount = bcount + 1
  108.     end
  109.     exit_msg("An internal error has occured. Please try again")
  110. end
  111.  
  112. /*
  113.  *  Exit Msg Procedure
  114.  */
  115. exit_msg: procedure expose
  116. do
  117.     parse arg message
  118.     if message ~= '' then call ppm_Inform(1, message,)
  119.     call ppm_AutoUpdate(1)
  120.     exit
  121. end
  122.  
  123.